
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../model/position_model.dart';

class ChannelItem extends StatefulWidget {
  ChannelModel channelModel;
  ChannelItem({super.key,required this.channelModel});

  @override
  State<ChannelItem> createState() => _ChannelItemState();
}

class _ChannelItemState extends State<ChannelItem> {

  Color getChannelColor(){
     return Color.fromRGBO((1.275*widget.channelModel.value!).toInt(), 0, (255-1.275*widget.channelModel.value!).toInt(), 1);
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 20,
      // color: Colors.amber,
      child: Row(mainAxisAlignment: MainAxisAlignment.center,crossAxisAlignment: CrossAxisAlignment.center,children: [
        Container(
          width: 10,
          child: Text("${widget.channelModel.index}",
              style: TextStyle(
                  color:Color(0xFF000000),
                  fontSize: 8,
                  fontWeight: FontWeight.w500)),
        ),
        Container(margin: EdgeInsets.fromLTRB(2,2,2,0), width: 10,height: 10,color: Colors.black,),
        Container(
          child: Text("${widget.channelModel!=null && widget.channelModel.value!>0?widget.channelModel.value:''}",
              style: TextStyle(
                  color: getChannelColor(),
                  fontSize: 10,
                  fontWeight: FontWeight.w500)),
        ),
        Container(margin: EdgeInsets.only(bottom: 2),
          child: Text("${widget.channelModel!=null && widget.channelModel.value!>0?'℃':''}",
              style: TextStyle(
                  color: getChannelColor(),
                  fontSize: 12,
                  fontWeight: FontWeight.w500)),
        ),
      ]),
    );
  }
}


